from sqlalchemy import Column, Integer, String, DateTime, Text, desc
from sqlalchemy.dialects.postgresql import ARRAY as PGArray
from sqlalchemy.ext.declarative import declarative_base
from datetime import datetime
BaseModel = declarative_base()


class RouteModel(BaseModel):
    __tablename__ = 'route'
    id = Column(Integer, primary_key=True, index=True)
    path = Column(String(64), nullable=False, comment="路径")
    summary = Column(String(32), nullable=True, comment="摘要")
    tags = Column(String(64), nullable=False,
                  default=[], comment="标签")
    methods = Column(String(32), nullable=False,
                     default=set(), comment="权限")
    endpoint = Column(String(32), nullable=False, comment="端点函数")
    permission = Column(String(32), nullable=False, comment="权限")
    update_time = Column(DateTime, default=datetime.now,
                         onupdate=datetime.now, comment="更新时间")
    description = Column(Text, nullable=True, comment="描述")